﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MediatR;
using PMS.Domain.AggregatesModel.MessaeAggregate;
using PMS.Domain.Events;


namespace PMS.Application.DomainEventHandler
{
    public class ProjectNotifactionDomianEventHandler : INotificationHandler<ProjectNotifactionDomianEvent>
    {

        public readonly IMessageCenterRepository _messageCenterRepository;

        public ProjectNotifactionDomianEventHandler(IMessageCenterRepository messageCenterRepository)
        {
            _messageCenterRepository = messageCenterRepository;
        }

        public async Task Handle(ProjectNotifactionDomianEvent notification, CancellationToken cancellationToken)
        {
            var message = new MessageCenter(notification.UserId, notification.Title, notification.Message);
            await _messageCenterRepository.CreateAsync(message);
           // await _messageCenterRepository.UnitOfWork.SaveEntitiesAsync();
        }

     
    }
}
